//part1:C07:7.7:ex7.7.cpp
#include <iostream>
#include "Sales_data.h"

using namespace std;

int main(void)
{
    cout << "Ener sales records(ISBN, volume, saleprice, sellprice)\n";
    Sales_data total;
    if (read_record(cin, total))
    {
        Sales_data trans;
        while (read_record(cin, trans))
        {
            if (total.isbn() == trans.isbn())
            {
                total = add(total, trans);
            }
            else
            {
                print_record(cout, total);
                cout << endl;
                total += trans;
            }
        }
        print_record(cout, total);
        cout << endl;
    }
    else
    {
       cerr << "No data?!" << endl;
       return -1;
    }
    return 0;
}
